<template>
	<svg aria-hidden="true" :class="svgClass" :style="style">
		<use :xlink:href="iconName"></use>
	</svg>
</template>

<script setup lang="ts">
const props = defineProps({
	iconClass: { type: String, required: true },
	className: { type: String, default: '' },
	size: { type: Number },
});

const iconName = computed(() => `#icon-${props.iconClass}`);
const svgClass = computed(() => {
	if (props.className) {
		return `svg-icon ${props.iconClass} ${props.className}`;
	}
	return `svg-icon ${props.iconClass}`;
});
const style = computed(() => {
	return {
		fontSize: props.size + 'px',
	};
});
</script>

<style scoped>
.svg-icon {
	width: 1em;
	height: 1em;
	overflow: hidden;
	vertical-align: -0.15em;
	fill: currentcolor;
}
</style>
